#include "ClientConnectionsManager.h"

#include <algorithm>
#include <boost/bind.hpp>

namespace AlgoTrading
{
	namespace ConnectionLibrary
	{

		ClientConnectionsManager::ClientConnectionsManager(void)
		{
		}

		ClientConnectionsManager::~ClientConnectionsManager(void)
		{
		}

		void ClientConnectionsManager::Start(ClientConnectionHandlerPtr connection)
		{
			connection->Start();
			connections.insert(connection);
		}

		void ClientConnectionsManager::Stop(ClientConnectionHandlerPtr connection)
		{
			connection->Stop();
			connections.erase(connection);
		}

		void ClientConnectionsManager::Remove(ClientConnectionHandlerPtr connection)
		{
			connections.erase(connection);
		}

		void ClientConnectionsManager::StopAll()
		{
			for(std::set<ClientConnectionHandlerPtr>::iterator it = connections.begin(); it != connections.end(); ++it)
			{
				(*it)->Stop();
			}
			connections.clear();

		}

	}
}
